﻿Public Class Frm1ItemsEditar
    Overloads Sub Show(ByVal p_ID As Integer, ByVal p_Nomb As String, ByVal p_Ori As String, ByVal p_Pres As String, ByVal p_Pes As Integer, ByVal p_Talla As String,
                       ByRef p_Costo As Integer, ByVal Frm1ItemsMenu As Frm1ItemMenuRMP)
        Me.lblTPRod.Text = p_ID
        Me.txtNombre.Text = p_Nomb
        Me.txtOrigen.Text = p_Ori
        Me.txtPresentacion.Text = p_Pres
        Me.txtPeso.Text = p_Pes
        Me.txtTalla.Text = p_Talla
        Me.txtCosto.Text = p_Costo

        Me.Show()
    End Sub
    Public Function cargarTipoProducto() As Boolean
        'Objeto Roles
        Dim accion As New ItemsDAO
        Dim dato As String = lblTPRod.Text
        'Tabla temporal de roles
        Dim tabla As DataTable
        tabla = accion.mostrar
        'Comprobar si hay roles
        If tabla Is Nothing Then
            Return False
        Else

            'Trabajar con el control combox
            With cbxTipo
                'No se permite modificar
                .DataSource = accion.mostrar
                'Fuentes de dtao
                .DropDownStyle = ComboBoxStyle.DropDownList
                'Campo a mostrar
                .DisplayMember = "Descripcion"
                'Clave principal
                .ValueMember = "ID_Tipo_Producto"
                'No mostrar ningun rol
                .SelectedIndex = dato - 1
            End With
            Return True
        End If
    End Function
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Frm1ItemMenuRMP.Show()
        Me.Close()

    End Sub

    Private Sub Frm1ItemsEditar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cargarTipoProducto()

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dato As New Items
        Dim accion As New ItemsDAO

        dato.pIdProd = lblTPRod.Text
        dato.pNombre = txtNombre.Text
        dato.pOrigen = txtOrigen.Text
        dato.pPresentacion = txtPresentacion.Text
        dato.pPeso = txtPeso.Text
        dato.pTalla = txtTalla.Text
        dato.pCosto = txtCosto.Text
        dato.pTipo = cbxTipo.SelectedValue


        If accion.actualizar(dato) Then
            MessageBox.Show("Registro actualizado", "Modificar", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else
            MessageBox.Show("No se puede modificar el registro, contacte al administrador", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End If
        Frm1ItemMenuRMP.Show()
        Me.Close()
    End Sub

    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter

    End Sub
End Class